from sqlalchemy import Column, Integer, String, func, DateTime, JSON, Boolean, ForeignKey
from sqlalchemy.orm import relationship

from models import Base


class CronTab(Base):
    """用例列表"""
    id = Column(Integer, primary_key=True, index=True, autoincrement=True)
    name = Column(String(100), unique=True, nullable=False, comment='定时任务名称')
    description = Column(String(200), comment='定时任务描述')
    isExecuteForbiddenedCase = Column(Boolean, default=False, comment='是否执行禁用的用例')
    testCaseSuiteIdList = Column(JSON, comment='任务执行的用例suiteId列表')
    testDomain = Column(String(100), comment='测试域名')
    next_run_time = Column(String(100), comment='下次执行时间')
    triggerType = Column(String(20), comment='触发类型')
    interval = Column(Integer, comment='触发间隔')
    alarmMailList = Column(JSON, comment='告警邮箱列表')
    status = Column(Boolean, default=True, comment='状态')
    createName = Column(String(20), nullable=False, comment='创建者')
    updateName = Column(String(20), comment='最后更新人')

    projectId = Column(Integer, ForeignKey('project.id', ondelete='CASCADE'), nullable=False, comment='项目ID')
    # project = relationship('Project')
